

#include "linked_network_fail.h"
#include "first_title.h"

static void again_btn_event_callback(lv_event_t * event)
{
    if(event->code == LV_EVENT_CLICKED)
    {
            //send recfg net cmd
        uint8_t flag = 1;
        pt_recnnt_flag_set(flag);
        //pt_ipc_send_msg(IPC_MSG_RECNNT_STAT,(char*)(&flag),1);

        debug_d("re-cnnt clicked\n");
        page_pop_anim_name(LOAD_ANIM_MOVE_LEFT,"add_dev");
    }
}

void ui_init_linked_network_fail_page_src(lv_obj_t *superview)
{
    first_title_set( FIRST_PAGE_NETWORKING, 0, 5);

    lv_obj_t * img = lv_img_create(superview);
    lv_img_set_src( img, pt_fs_get("Warning.png"));
    lv_obj_align( img,LV_ALIGN_TOP_LEFT,186,82);

    lv_obj_t * label = lv_label_create(superview);
    lv_obj_set_style_text_font( label, lv_font_get(20), LV_STATE_DEFAULT );
    lv_obj_set_style_text_color(label,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN);
    lv_obj_set_style_text_opa(label,LV_OPA_80,0);
    lv_label_set_text( label, "联网失败");
    lv_obj_align( label, LV_ALIGN_TOP_LEFT,182,171);

    lv_obj_t * btn = lv_btn_create(superview);
    lv_obj_set_style_radius(btn, LV_PCT(25), LV_PART_MAIN);
    lv_obj_set_style_outline_width(btn, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN);
    lv_obj_set_style_bg_color(btn,lv_color_make(0x26,0x7a,0xff),0);
    lv_obj_set_style_bg_opa(btn,LV_OPA_100,0);
    lv_obj_set_pos(btn,52,250);
    lv_obj_set_size(btn,350,50);

    lv_obj_t * btn_label = lv_label_create(btn);
    lv_obj_set_style_text_font( btn_label, lv_font_get(24), LV_STATE_DEFAULT );//字体大小
    lv_label_set_text(btn_label,"重新配网");
    lv_obj_center(btn_label);

    lv_obj_add_event_cb(btn, again_btn_event_callback, LV_EVENT_ALL, NULL);
}

static void network_fail_page_on_custom_attr_config(page_base_t* self)
{
    return ;
}
static void network_fail_page_on_view_load(page_base_t* self)
{
    ui_init_linked_network_fail_page_src(self->root);
    return ;
}
static void network_fail_page_on_view_did_load(page_base_t* self)
{
    return ;
}
static void network_fail_page_on_view_will_appear(page_base_t* self)
{
    return ;
}
static void network_fail_page_on_view_did_appear(page_base_t* self)
{
    return ;
}
static void network_fail_page_on_view_will_disappear(page_base_t* self)
{
    return ;
}
static void network_fail_page_on_view_did_disappear(page_base_t* self)
{
    return ;
}
static void network_fail_page_on_view_did_unload(page_base_t* self)
{
    return ;
}

static page_vtable_t page_param = {
    .on_custom_attr_config  = network_fail_page_on_custom_attr_config,
    .on_view_load           = network_fail_page_on_view_load,
    .on_view_did_load       = network_fail_page_on_view_did_load,
    .on_view_will_appear    = network_fail_page_on_view_will_appear,
    .on_view_did_appear     = network_fail_page_on_view_did_appear,
    .on_view_will_disappear = network_fail_page_on_view_will_disappear,
    .on_view_did_disappear  = network_fail_page_on_view_did_disappear,
    .on_view_did_unload     = network_fail_page_on_view_did_unload,
};


page_vtable_t* lv_page_linked_network_fail_create(void)
{
    return &page_param;
}
